<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>商品添加</title>
</head>
<body>
<div id="content">
    <h3 class="admin_link_bar">
        <jsp:include page="inc.jsp"/>
    </h3>
    <sf:form method="post" enctype="multipart/form-data" modelAttribute="product">
        <table width="600" class="thin-border" align="center">
            <tr>
                <td>商品名称：</td>
                <td><sf:input path="name" value="${product.name}"/><span
                        class="errorContainer"></span></td>
            </tr>
            <tr>
                <td>商品价格：</td>
                <td><sf:input path="price" value="${product.price }"/><span
                        class="errorContainer"></span></td>
            </tr>
            <tr>
                <td>商品库存：</td>
                <td><sf:input path="stock" value="${product.stock }"/><span
                        class="errorContainer"></span></td>
            </tr>

            <tr>
                <td>商品类别：</td>
                <td>
                    <sf:select path="cId">
                        <sf:option value="">请选择商品类别</sf:option>
                        <c:forEach items="${cs }" var="c">
                            <c:if test="${c.id eq param.cId }">
                                <sf:option value="${c.id }" selected="selected">${c.name }</sf:option>
                            </c:if>
                            <c:if test="${c.id ne param.cId }">
                                <sf:option value="${c.id }">${c.name }</sf:option>
                            </c:if>
                        </c:forEach>
                    </sf:select>
                    <span class="errorContainer"></span></td>
            </tr>
            <tr>
                <td>商品图片：</td>
                <td><input type="file" name="attachs" value="${product.img}" accept="image/gif, image/jpeg"/><span
                        class="errorContainer"></span>
                </td>
            </tr>
            <tr>
                <td colspan="2">商品介绍：</td>
            </tr>
            <tr>
                <td colspan="2"><textarea cols="90" rows="10" name="intro">${product.intro }</textarea></td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="submit" value="添加"/><input type="reset"/>
                </td>
            </tr>
        </table>
    </sf:form>
</div>
</body>
</html>